package com.stox.core.lifecycle;

import java.awt.*;
import javax.swing.*;

import com.stox.resources.image.ImageIconLoader;

public class SplashScreen extends JWindow {
	private static final long serialVersionUID = -2830568318390416223L;

	private String imagePath;
	
	public SplashScreen(String imagePath) {
		this.imagePath = imagePath;
	}
	
	public void showSplash() {
		JPanel content = (JPanel) getContentPane();
		content.setBackground(Color.white);

		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		int width = screen.width/3;
		int height = screen.height/3;
		int x = (screen.width - width) / 2;
		int y = (screen.height - height) / 2;
		setBounds(x, y, width, height);

		JLabel label = new JLabel(ImageIconLoader.loadImageIcon(imagePath, width, height));
		JLabel copyrt = new JLabel("Copyright 2002, O'Reilly & Associates",JLabel.CENTER);
		copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
		content.add(label, BorderLayout.CENTER);
		content.add(copyrt, BorderLayout.SOUTH);
		setVisible(true);
	}

}
